package com.nj.dms.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.nj.dms.bean.PaperMoldDocument;
import com.nj.dms.dao.PaperMoldDocumentDao;
import com.nj.dms.dao.impl.PaperMoldDocumentDaoImpl;

/**
 * 修改纸版文档
 */
@WebServlet("/UpdatePaperMoldDocument")
public class UpdatePaperMoldDocument extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		// 获取需要查询文档的ID
		int id = new Integer(request.getParameter("id"));

		PaperMoldDocumentDao pmddi = new PaperMoldDocumentDaoImpl();

		PaperMoldDocument pmd = pmddi.findPaperMoldDocument(id);

		if (pmd != null) {

			// 文档找到，跳转到查看页

			request.setAttribute("paperMoldDocument", pmd);

			request.getRequestDispatcher("document/update-paper-mold-document.jsp").forward(request, response);

		} else {
			// 文档未找到，跳转到文档列表

			response.sendRedirect("MyPaperMoldDocumentList");

		}

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
